﻿@using Seal.Model
@using Seal.Helpers
@{
    Report report = Model;
    ReportView view = report.CurrentView;
    ReportModel reportModel = view.Model;
}

@if (report.Format == ReportFormat.csv)
{
    @Include(view.GetPartialTemplateKey("ModelDetail.iCSV", view), view)
}
else
{
<div id='@("model_" + view.IdSuffix)' @Raw(view.AddAttribute("class", "modeldetail_class")) @Raw(view.AddAttribute("style", "modeldetail_css"))>

    @foreach (ResultPage page in reportModel.Pages)
    {
        <div>
            @if (page.PageTable != null && page.PageTable.RowCount == 2 && page.PageTable.ColumnCount > 0)
            {
                <table class='table table-striped table-hover table-bordered' @Raw(view.AddAttribute("style", "pagetable_css"))>
                    <tr>
                        @for (int i = 0; i < page.PageTable.ColumnCount; i++)
                        {
                            ResultCell value = page.PageTable[1, i];
                            <th @Raw(Helper.AddAttribute("class", value.CellCssDetailClass)) @Raw(Helper.AddAttribute("style", value.CellCssDetailStyle)) >@Raw(value.HTMLValue)</th>
                        }
                    </tr>
                </table>

                <hr style="display: block;" />
            }


            @if (page.DataTable != null && page.DataTable.RowCount == 2)
            {
                <table class='table table-striped table-hover table-bordered' @Raw(view.AddAttribute("style", "datatable_css"))>
                    @for (int i = 0; i < page.DataTable.ColumnCount; i++)
                    {
                        ResultCell title = page.DataTable[0, i];
                        ResultCell value = page.DataTable[1, i];
                        <tr>
                                <th @Raw(Helper.AddAttribute("class", title.CellCssDetailClass)) @Raw(Helper.AddAttribute("style", title.CellCssDetailStyle))>@Raw(title.HTMLValue)</th>
                                <td @Raw(Helper.AddAttribute("class", value.CellCssDetailClass)) @Raw(Helper.AddAttribute("style", value.CellCssDetailStyle))>@Raw(value.HTMLValue)</td>
                        </tr>
                    }
                </table>
            }
        </div>
    }
</div>
}
